package com.example.utils;

import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

public class HttpClientWrapper {
    public static String getRequest() throws IOException {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpGet httpGet = new HttpGet("https://p26-sign.douyinpic.com/obj/joker/weshine/43aac81ce99dccce48765ae311a187d2.gif?x-expires=1685523600&x-signature=7pPaWIrmqXYf1AWwYWZEqbGKBZw%3D&from=2668313166");
        CloseableHttpResponse response1 = httpclient.execute(httpGet);
        try {
            System.out.println(response1.getStatusLine().getStatusCode());
            HttpEntity entity1 = response1.getEntity();
            // do something useful with the response body
            // and ensure it is fully consumed
            EntityUtils.consume(entity1);
        } finally {
            response1.close();
        }
        return "";
    }

    public static void main(String[] args) throws IOException {
        getRequest();
    }
}
